﻿using System.Xml;
using Blackbird.Common.Properties;
using Blackbird.Core.Editable.Base;

namespace Blackbird.Core.Editable.Map
{
    public class EditableBackground : BaseEditableEntity
    {
        public EditableBackground()
        {
            MapLayers = new EditableLayeredMap();
        }

        public EditableLayeredMap MapLayers { get; private set; }

        protected override void ReadXmlContent(XmlReader reader)
        {
            reader.ReadStartElement("maplayers");
            reader.MoveToContent();
            while (reader.NodeType != XmlNodeType.EndElement)
            {
                var map = new EditableMapLayer();
                map.ReadXml(reader);
                MapLayers.Add(map);
                reader.Read();
            }
        }

        protected override void WriteXmlContent(XmlWriter writer)
        {
            writer.WriteStartElement("maplayers");
            foreach (EditableMapLayer map in MapLayers)
            {
                map.WriteXml(writer);
            }
            writer.WriteEndElement();
        }

        public override string TypeName
        {
            get { return Resources.EditableBackgroundTypeFiendlyName; }
        }

        protected override void ReadXmlAttributes(XmlReader reader)
        {
        }

        protected override void WriteXmlAttributes(XmlWriter writer)
        {
        }
    }
}